      SUBROUTINE DAMPER(ZMSDB,ZMDDB)
C
C        'DAMPER' COMPUTES INTERNAL FORCES FOR LIBRATION DAMPER SPRING
C        MOMENT,VISCOUS DAMPING MOMENT,AND MAGNETIC HYSTERESIS MOMENT
C        IF IDAMP=0 ALSO SETS ITIM=2
C        IF THE DAMPER HAS NOT HIT THE STOP, IT COMPUTES THE SPRING
C        RESTORING MOMENT FROM MSDB=K1D*PHILD
C
      IMPLICIT REAL*8 (A-H,O-Z)
C
      COMMON/CONSTS/ PI,TWOPI,RADIAN
C
      COMMON/IPOOL1/ IGRAV,IDAMP,IK,K1,ITIM,IAB,IAPS,IBB,IBPS,NK(10),
     .               LK(10),LLK(10)
C
      COMMON/LIBDPR/ ZK1D,ZK2D,PHIS,PHILD,DPHILD,BETLD,GAMLD,
     .               ZMDO,ZMDBO,CNV,DECAY
C
      COMMON/RPOOL1/ RHOK(10),TIME,SA(3,3),FM1(3,3),ZLK(10),OMEG(3),
     .               ZLKP(10),ZLKDP(10),CMAT(3,3),GBAR(3,3),YBCM(3),
     .               ZBZK(3,10),FCM(3,3),DTO,PHID,PHI
C
      DATA KNTRY /1/
C
      IF(IDAMP.EQ.0) GO TO 100
      PHA=DABS(PHI)
      IF(PHA-PHIS*RADIAN.GT.0.D0) GO TO 10
      ZMSDB=-ZK1D*PHI
      GO TO 30
C
   10 IF(PHI-PHIS*RADIAN.LE.0.D0) GO TO 20
      ZMSDB=-ZK1D*PHIS*RADIAN - ZK2D*(PHI - PHIS*RADIAN)
      GO TO 30
C
   20 ZMSDB= ZK1D*PHIS*RADIAN - ZK2D*(PHI - PHIS*RADIAN)
   30 ZMSDB=ZMSDB - CNV*PHID
      IF(KNTRY.EQ.2) GO TO 40
      KNTRY=2
      ZMDLM=ZMDBO
      ZMDLP=ZMDBO
      PHLP=PHI
      PHLM=PHI
      GO TO 60
C
   40 IF(PHID.GE.0.D0) GO TO 50
      PHLM=PHI
      ZMDLP=ZMDDB
      GO TO 60
C
   50 PHLP=PHI
      ZMDLM=ZMDDB
   60 IF(PHID.LT.0.D0) GO TO 80
      AB=(PHI-PHLM)
      ZMDDBP=-2.D0*ZMDO*(1.D0 - DEXP(-DECAY*AB)) + ZMDLP
      ZMDM=-ZMDO
      IF(ZMDDBP-ZMDM.GE.0.D0) GO TO 70
      ZMDDB=ZMDM
      RETURN
   70 ZMDDB=ZMDDBP
      RETURN
   80 AB=(PHLP-PHI)
      ZMDDBM=2.D0*ZMDO*(1.D0 - DEXP(-DECAY*AB)) + ZMDLM
      IF(ZMDDBM-ZMDO.GE.0.D0) GO TO 90
      ZMDDB=ZMDDBM
      RETURN
   90 ZMDDB=ZMDO
      RETURN
  100 ZMSDB=0.D0
      ZMDDB=0.D0
      ITIM=2
      RETURN
      END
